package com.qf.utils;

import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.pool.DruidDataSourceFactory;

import javax.sql.DataSource;
import java.util.Properties;

/**
 * Created by Administrator on 2021/10/19.
 */
public class DBtools {

    //数据源
    private static DruidDataSource dataSource;

    static {
        Properties properties = new Properties();

        try {
            properties.load(DBtools.class.getClassLoader().getResourceAsStream("db.properties"));
            dataSource = (DruidDataSource) DruidDataSourceFactory.createDataSource(properties);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    //获得数据源
    public static DataSource getDataSource() {
        return dataSource;
    }
}
